package com.flca.frw.model
{
	import com.flca.frw.interfaces.IModel;
	
	import mx.collections.ArrayCollection;
	import mx.controls.Alert;
	import mx.controls.dataGridClasses.DataGridColumn;
	
	public class ModelBase implements IModel
	{
		protected var forObject : Object;
//		protected var masterObject : Object;
//		protected var masterClass : Object;
		protected var entity : Object;
			
		public function getLabel(source:Object):String
		{
			return source.toString();
		}
		
		public function getGridColumns():Array
		{
			return null;
		}
		
		public function getLookupColumns():Array
		{
			return null;
		}
		
		protected function addColumn( arr:Array, propName:String, headerName:String = null) : void
		{
			var col:DataGridColumn = new DataGridColumn();
			col.dataField = propName;
			if (headerName != null) {
				col.headerText = headerName;
			}
			arr.push(col);
		}
		
		protected function addColumnFunc( arr:Array, propName:String, labelfunc:Function, headerName:String = null) : void
		{
			var col:DataGridColumn = new DataGridColumn();
			col.dataField = propName;
			if (headerName != null) {
				col.headerText = headerName;
			}
			if (labelfunc != null) {
				col.labelFunction = labelfunc;
			}
			arr.push(col);
		}
		

		public function getLookupValues() : ArrayCollection 
		{
			Alert.show("Override getLookupValues()!!");
			return new ArrayCollection();
		}
		
		public function makeNew() : void
		{
			Alert.show("Override makeNew()!!");
		}
		
		public function getEntity() : Object 
		{
			return entity;	
		}
		
		public function assemble(sourceValue:Object) : Object
		{
			//Override this method for example if you use a JoinTable
			return sourceValue;
		}
		
//		public function getMaster() : Object {
//			return masterObject;
//		}
		
	}
}